﻿<%@page import="com.hh.bss.common.cache.SystemUserCache" %>
<%@page import="com.hh.bss.auth.entity.SystemMenu" %>
<%@page import="java.util.*" %>
<%
   Integer userId=(Integer)request.getAttribute("userId");
%>
<%
   System.out.println("userId:"+userId);
%>
<!DOCTYPE html>
<html>  
<head>  
    <meta charset="UTF-8">  
    <title>Basic Layout - jQuery EasyUI Demo</title>  

    <%@ include file="/WEB-INF/inc/default.jsp"%> 
     <jsp:include page="/WEB-INF/inc/dic.jsp"/> 
     	
    <script type="text/javascript" src="/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript" src="/js/tiny.js"></script>     	
    <style type="text/css">

    
    body{height:650px;bgcolor:red}


</style> 	
<body>  
  
    <div class="easyui-layout" align=center style="border:0px solid #ddd;bgcolor:red;width:100%;height:100%;overflow:hidden">  
        <div data-options="region:'north'" style="border:8px;height:40px">  
        
            <div style="padding:3px;border:0px solid #ddd">  
            <div >
            <%
               SystemMenu one = null;
               Map menuMap=SystemUserCache.getUserRootMenu(userId);
               for (Iterator it =menuMap.values().iterator(); it.hasNext();) {
                  one = (SystemMenu) it.next();
                  %>
                    <a href="#" class="easyui-menubutton" style="background: #d0def0 url(/images/bg.gif) repeat-x top left" data-options="menu:'#menu_<%=one.getId()%>',iconCls:'<%=one.getAppClass()%>'"><%=one.getText()%></a>
                  <%
               }
            %>
          </div>
            <div  style="background: #d0def0 url(/images/bg.gif) repeat-x top left">
            <a  style="position:absolute;top:13px;right:250px">欢迎您:</a>
            <a id="ausername" style="position:absolute;top:13px;right:200px"></a>
            <a href="#" onclick="modifyPassword();" class="easyui-linkbutton" style="position:absolute;top:8px;right:100px" data-options="plain:true">修改密码</a>  
            <a href="#" onclick="logout();" class="easyui-linkbutton" style="position:absolute;top:8px;right:60px" data-options="plain:true">登出</a>  
          </div>	
            </div>
            
        </div>

            
        
        <div data-options="region:'center',iconCls:'icon-ok'"  style="border:0px solid #ddd;height:100%;width:100%">  
            <div id="tab_panel" class="easyui-tabs" border="0"  style="border:0;height:610px">  
                <div title="主界面"  style="border-style:none;padding-top:8px;margin-left: 0px;margin-right: 0px">  
                    <div class="easyui-layout" border="0" align=center style="width:100%;height:560px;overflow:hidden">  
                    	    
                          <div data-options="region:'north'"   style="height:200px">  
                          
                               <div >  
                               	   <div class="ftitle">业务动态</div> 
                                   <marquee style="height:155px" bgcolor="#F5F5F5" scrollamount=2 direction=up >da11tadata</marquee>
                               </div>
                          </div>

            
        
                          <div data-options="region:'center',iconCls:'icon-ok'">  
                               <div id="tab_panel" class="easyui-tabs" border="0" style="padding:5px;height:340px">  
                                    <div title="工作计划" border="0" style="padding:5px;height:400px" >  
                                      
                                            <table id="dg-plan"  style="height:300px"
                                             url="/project/plan/list.do"  
                                             pagination="true"  
                                             rownumbers="true" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false"> 
                                              </table> 
                                    </div>  
                                    <div title="新闻公告" border="0" style="padding:5px;height:400px">  
                                    	    <table id="dg-news"   style="height:300px"
                                             url="/oa/oaNews/desktoplist.do"  
                                             pagination="true"  
                                             rownumbers="true" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false"> 
                                           </table> 
                                    </div>  
                                   
                               </div>  
                          </div>  
                          </div>  
                                
                          <div style="clear:both;"></div>   
                </div>  
          
            </div>  
        </div>  
    </div>  
    <%
              
              
               for (Iterator it =menuMap.values().iterator(); it.hasNext();) {
                  one = (SystemMenu) it.next();
                  out.println(SystemUserCache.getUserParentChildMenuScript(userId,one.getId()));
               }
    %>
    <div style="clear:both;"></div> 
    
    
    <div id="dlg" style="display:none;">  
        <!--    
        <form id="fm" method="post" novalidate>  
        	  	  	  
        	  	  	 <input type="hidden" name="username" >	        		             		     
	        		     <div class="fitem">  
                     <label style="width:100px">旧密码:</label>                                            
                     <input name="oldpassword" type="password" class="easyui-box">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">新密码:</label>                                            
                     <input name="newpassword" type="password" class="easyui-box">                       
                   </div> 	 
                   <div class="fitem">  
                     <label style="width:100px">重复新密码:</label>                                            
                     <input name="rnewpassword" type="password" class="easyui-box">                       
                   </div>        		          		     	        		        
	        		     
        </form>  
        <div  style="text-align:center">  
          <a href="javascript:void(0)" id="btn-save" class="easyui-linkbutton" iconCls="icon-ok" ">修改</a>  
          <a href="javascript:void(0)" id="btn-close" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>  
        </div>
        -->
    </div> 
</body>  
</html>
<script>

     var optWin = $.window({
		       		 title:"修改密码",
		       		 tplRef:"dlg",//这个属性指定模板id
		       		 height:200,		       		 
		       		 closed:true,		       		 
		       		 onComplete:function(){
		       		 	  //窗口里面的初始化,最好是在这个事件里面进行
		       		 	  var curWin=this;
		       		 	  var doForm=curWin.find('#fm');
		       		 	  curWin.doForm=doForm;
		       		 	  this.find("#btn-close").click(function(){		       		 	  	
		       		 	  	   curWin.window('close');
		       		 	  });
		       		 	  this.find("#btn-save").click(function(){		       		 	  	
		       		 	      
		                 		  if (!doForm.form('validate')) return;
		                 		  alert(doForm.find('input[name="rnewpassword"]').val());
		                 		  if (doForm.find('input[name="rnewpassword"]').val()!=doForm.find('input[name="newpassword"]').val()){
		                 		  	  alert('新密码两次输入不一致。');
	                            return;
	                        }
		                 		  
		                 		  
		                 		  doForm.form('submit',{  
                            url: curWin.url,  
                            onSubmit: function(){                              	  
                                return doForm.form('validate');  
                            },  
                            success: function(result){  
                                var result = eval('('+result+')');                      
                                if (result.success == true){  
                                    //$.messager.alert('信息',result.msg,'info');  
                                    alert(result.msg);
                                    curWin.window('close');
                                    
                                    
                                } else {  
                                    //$.messager.alert('错误',result.msg,'error');
                                    alert(result.msg);
                                }  
                            }  
                       }); 		 
		              });
		       		   
		       		 }
		    });
        function modifyPassword(){
        	  optWin.window('open'); 
            optWin.openWin=window;    
            optWin.url='/auth/systemUser/modifypassword.do';  
            optWin.doForm.form('clear');
             optWin.doForm.find('input[name="username"]').attr("value",_getUsername());
            optWin.window('setTitle','修改密码');
        }
        
        
        function tabAdd(tabPanel,id,title,url){
             //如果存在，则当前激活
             var tab = $('#'+id);
             if (tab.length > 0) {
                 var index = tabPanel.tabs('getTabIndex',tab);
                 tabPanel.tabs('select',index);
                 return;
             }
             tabPanel.tabs('add',{                                                                                                       
		               	id:id,		               	
		                title: title,                                                                                                     
		                content: '<iframe frameborder=0 scrolling="no" src="'+url+'" style="width:100%;height:99%;padding:0px"/>',                                                            		               
		                closable: true                                                                                                          
		            }); 
		         authWidthHight(id);   //为什么不起作用？？
		            
        }
	function add(){                  
		
	     tabAdd($('#tab_panel'),'tab_baidu','百度','http://www.baidu.com');	
	     
                                                                                                                         
        } 
 function logout(){
	        	 	        	
	        	 window.location.href='/auth/systemUser/userlogout.do';
 }      
  function authWidthHight(fid){
  	 // alert('auto:'+fid);
  	  $("#"+fid).load(function(){
  	  	// alert('load');
         var mainheight = $(this).contents().find("body").height()+30;
         $(this).height(mainheight);
       }); 
  }	      
	function openPanel(pid,pname,url){     
		    //增加自适应宽度和高度
		    
		             		
	      tabAdd($('#tab_panel'),pid,pname,url);	
        }    
        
   $('#dg-plan').datagrid({
        	   columns:[[
        	   	        	   	        	   	
        	   	   {field:'plantype_name',title:'工作类型', width:100}
        	   	   ,{field:'cvName',title:'人选', width:100}
        	   	   ,{field:'jobName',title:'职位', width:100}        	   	  
        	   	   ,{field:'expiredDt',title:'计划时间', width:100}
        	   	   ,{field:'expiredT',title:'到期时间', width:100}
        	   	
        	   ]]
        	   
        }); 
	$('#dg-news').datagrid({
        	   columns:[[
        	   	        	   	        	   	
        	   	   {field:'title',title:'标题', width:100}
        	   	   ,{field:'createDt',title:'公布日期', width:100}
        	   	  
        	   	
        	   ]]
        	   
        });    
    $('#ausername').html(_getName());           
</script>